﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


class FractionNumber : IFormattable
{
    private int numerator;
    private int denominator;

    public int Numerator
    {
        get { return numerator; }
        set { numerator = value; }
    }

    public int Denominator
    {
        get { return denominator; }
        set { denominator = value; }
    }

    private double Number
    {
        get { return ((double)this.Numerator) / this.Denominator; }
    }

    public FractionNumber(int numerator, int denominator)
    {
        this.Numerator = numerator;
        this.Denominator = denominator;
    }

    public override string ToString()
    {
        return this.Number.ToString();
    }

    public string ToString(string format, IFormatProvider formatProvider)
    {
        if (format == "N")
        {
            return String.Format("{0}/{1}",this.Numerator, this.Denominator);
        }

        if (format == "R")
        {
            return String.Format("{0:0.##}", this.Number);
        }

        if (format == null)
        {
            return this.ToString();
        }

        throw new FormatException(String.Format("Invalid format: {0}", format));

    }

}

